{% extends "base.html" %} {% block title %}我的健康计划 - 运动健康管理系统{%
endblock %} {% block content %}
<div class="container py-5">
  <div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="mb-0"><i class="bi bi-calendar-check"></i> 我的健康计划</h1>
    <a href="{{ url_for('create_plan') }}" class="btn btn-primary">
      <i class="bi bi-plus-circle"></i> 创建新计划
    </a>
  </div>

  <!-- 显示闪现消息 -->
  {% with messages = get_flashed_messages() %} {% if messages %} {% for message
  in messages %}
  <div class="alert alert-info alert-dismissible fade show" role="alert">
    {{ message }}
    <button
      type="button"
      class="btn-close"
      data-bs-dismiss="alert"
      aria-label="Close"></button>
  </div>
  {% endfor %} {% endif %} {% endwith %} {% if plans %}
  <div class="row">
    {% for plan in plans %}
    <div class="col-md-6 col-lg-4 mb-4">
      <div class="card h-100 shadow-sm">
        <div class="card-body">
          <h5 class="card-title">{{ plan.plan_name }}</h5>
          <p class="card-text text-muted">
            <small>创建于: {{ plan.created_at.strftime('%Y-%m-%d') }}</small>
          </p>
          <p class="card-text">{{ plan.description|truncate(100) }}</p>
          <div class="d-flex justify-content-between align-items-center">
            <span class="badge bg-primary"
              >{{ plan.start_date.strftime('%Y-%m-%d') }}</span
            >
            {% if plan.end_date %}
            <span class="badge bg-secondary"
              >{{ plan.end_date.strftime('%Y-%m-%d') }}</span
            >
            {% else %}
            <span class="badge bg-secondary">长期</span>
            {% endif %}
          </div>
        </div>
        <div class="card-footer bg-transparent">
          <a
            href="{{ url_for('plan_detail', plan_id=plan.id) }}"
            class="btn btn-outline-primary w-100"
            >查看详情</a
          >
        </div>
      </div>
    </div>
    {% endfor %}
  </div>
  {% else %}
  <div class="alert alert-info">
    <p class="mb-0">
      您还没有创建任何健康计划。点击上方的"创建新计划"按钮开始制定您的健康计划吧！
    </p>
  </div>
  {% endif %}
</div>
{% endblock %}
